package com.xiaoxing.salesclient.mvp.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.ArmsUtils;
import com.xiaoxing.salesclient.mvp.model.entity.ProductList;

import java.util.List;

import me.jessyan.armscomponent.commonsdk.core.RouterHub;
import me.jessyan.armscomponent.commonsdk.utils.Utils;
import xiaoxing.com.salesclient.R;


public class ChanPinJiaGeTabAdapter extends BaseQuickAdapter<ProductList.DataBean, BaseViewHolder> {

    private Context mContext;

    public ChanPinJiaGeTabAdapter(Context context, @Nullable List<ProductList.DataBean> data) {
        super(R.layout.item_chan_pin_jia_ge_tab, data);
        this.mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, ProductList.DataBean item) {

        TextView tv_xiang_qing = helper.getView(R.id.tv_xiang_qing);
        TextView tv_ding_gou = helper.getView(R.id.tv_ding_gou);

        tv_xiang_qing.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                if (tv_ding_gou.getVisibility() == View.GONE) {
//                    tv_ding_gou.setVisibility(View.VISIBLE);
//                    tv_xiang_qing.setVisibility(View.GONE);
//                } else {
//                    tv_ding_gou.setVisibility(View.GONE);
//                }

//                Utils.navigation(mContext, RouterHub.SALES_CLIENT_CHAN_PIN_XIANG_QING_ACTIVITY);
                ARouter.getInstance().build(RouterHub.SALES_CLIENT_CHAN_PIN_XIANG_QING_ACTIVITY).withString("product_id", item.getProduct_id()).navigation(mContext);
            }
        });
        tv_ding_gou.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ArmsUtils.snackbarText("訂購成功");
            }
        });

        helper.setText(R.id.tv_nama, item.getProduct_name());
        helper.setText(R.id.tv_num, item.getPrice() + "元");
    }
}
